home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / macros / latex209 / contrib / oval / oval.sty < prev    next >
Text File  |  1991-10-26  |  4KB  |  114 lines

  1. \message{OVAL Boxes (c) by Elmar Schalueck 1991}
  2. \catcode`\@=11          % Make @ a letter
  3. \newbox\@tmpbox         % to save a box
  4. \newbox\@cornerbox      % to save a corner
  5. \newdimen\@tmpradius%
  6. \newdimen\@tmprule%
  7. \newdimen\@tmpdimadd%
  8. \newdimen\@tmpsep%
  9. \newdimen\@tmpdimd        % dimen of depth
  10. \newdimen\@tmpdimh        % dimen of height
  11. \newdimen\@tmpdimw        % dimen of width
  12. \newdimen\@cornerdimw     % dimen of width of a corner
  13. \newdimen\@vboxheight     % dimen of height of surrounding box
  14. \newdimen\@hboxwidth      % dimen of width of surrounding box
  15. \font\@cornerfont = newcirc     % font for corners
  16. \newcount\@tmpchar%
  17. \newcount\@tmpcount%
  18. %
  19. %
  20. %
  21. % \@getovalradius calculates the real radius of the corners
  22. %
  23. \def\@getovalradius
  24. {\global\@tmpsep=2pt
  25. \ifdim\fboxsep>14\@tmpsep\@tmpcount=7\else
  26. \ifdim\fboxsep>12\@tmpsep\@tmpcount=6\else
  27. \ifdim\fboxsep>10\@tmpsep\@tmpcount=5\else
  28. \ifdim\fboxsep>8\@tmpsep\@tmpcount=4\else
  29. \ifdim\fboxsep>6\@tmpsep\@tmpcount=3\else
  30. \ifdim\fboxsep>4\@tmpsep\@tmpcount=2\else
  31. \ifdim\fboxsep>2\@tmpsep\@tmpcount=1\else
  32. \global\@tmpcount=0\fi\fi\fi\fi\fi\fi\fi
  33. \global\@tmpchar=4\global\multiply\@tmpchar by\@tmpcount
  34. \advance\@tmpcount by 1
  35. \global\multiply\@tmpsep by\@tmpcount}
  36. %
  37. %
  38. % \@gettmprule calculates real line width
  39. %
  40. \def\@gettmprule
  41. {\global\@tmprule=.4pt
  42. \ifdim\fboxrule>3\@tmprule\@tmpcount=3\else
  43. \ifdim\fboxrule>2\@tmprule\@tmpcount=2\else
  44. \ifdim\fboxrule>\@tmprule\@tmpcount=1\else
  45. \@tmpcount=0\fi\fi\fi
  46. \advance\@tmpcount by 1
  47. \global\@tmprule=.4pt\global\multiply\@tmprule by\@tmpcount
  48. \advance\@tmpcount by -1
  49. \multiply\@tmpcount by 32
  50. \global\advance\@tmpchar by\@tmpcount}
  51. %
  52. %
  53. %
  54. % \ovalbox#1 defines a box with round corners to enclose #1
  55. %
  56. \long\def\ovalbox#1{%
  57.  \leavevmode\setbox\@tmpbox\hbox{#1}     % make #1 a box
  58.  \@getovalradius%
  59.  \@gettmprule%
  60.  \setbox\@cornerbox\hbox{\@cornerfont\char\@tmpchar}%
  61.  \@cornerdimw=\wd\@cornerbox%
  62.  \@tmpdimd=\dp\@tmpbox                   % depth of box, i.e. the part beneath
  63.                                          % the baseline
  64.  \@tmpdimh=\ht\@tmpbox                   % part above baseline
  65.  \@tmpdimw=\wd\@tmpbox                   % width of box
  66.  \advance\@tmpdimh by\@tmpdimd           % total height of original box
  67.  \@hboxwidth=\fboxsep%
  68.  \advance\@hboxwidth by \fboxsep%
  69.  \@vboxheight=\@hboxwidth%
  70.  \advance\@hboxwidth by \@tmpdimw        % total width of surrounding box
  71.  \advance\@vboxheight by \@tmpdimh       % total height of surrounding box
  72.  \advance\@tmpdimd by\fboxsep%
  73.  \advance\@tmpdimd by\@tmprule           % total amount beneath baseline
  74.  \@tmpdimadd=\fboxsep%
  75.  \advance\@tmpdimadd by -\@tmpsep%
  76.  \multiply\@tmpdimadd by 2               % calculate additional length
  77.  \advance\@tmpdimh by\@tmpdimadd         % calculate height of vrule
  78.  \advance\@tmpdimw by\@tmpdimadd         % calculate width of hrule
  79.  \hbox{\lower\@tmpdimd                   % put a box beneath baseline
  80.   \hbox%
  81.    {\vbox%
  82.      {\hbox{\@cornerfont \char \@tmpchar}%
  83.       \nointerlineskip%
  84.       \global\advance\@tmpchar by 1%
  85.       \hbox{\hskip-0.5\@tmprule%
  86.             \vrule height\@tmpdimh width\@tmprule depth0pt}%
  87.       \nointerlineskip%
  88.       \hbox{\@cornerfont \char \@tmpchar}%
  89.       \global\advance\@tmpchar by 1%
  90.      }\relax%
  91.     \lower0.5\@tmprule\vbox
  92.      {\hrule width\@tmpdimw height\@tmprule depth0pt\relax%
  93.       \vskip\fboxsep%
  94.       \vskip-0.25\@tmprule%
  95.       \hbox%
  96.        {\hskip0.5\@tmpdimadd%
  97.         \box\@tmpbox\relax                       % place original box
  98.        }%
  99.       \vskip\fboxsep%
  100.       \hrule width\@tmpdimw height\@tmprule depth0pt\relax%
  101.      }\relax%
  102.     \vbox%
  103.      {\hbox{\@cornerfont \char \@tmpchar}%
  104.       \nointerlineskip%
  105.       \global\advance\@tmpchar by 1%
  106.       \hbox{\hskip\@tmpsep\hskip-0.5\@tmprule%
  107.             \vrule height\@tmpdimh width\@tmprule depth0pt}%
  108.       \nointerlineskip%
  109.       \hbox{\@cornerfont \char \@tmpchar}%
  110.      }%
  111.    }}}%
  112. %
  113. \catcode`\@=12%
  114.